package com.woniu.account.controller;


import com.woniu.account.model.TPermission;
import com.woniu.account.service.TPermissionService;
import com.woniu.core.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 吴彦祖
 * @since 2024年04月02日
 */
@RestController
@RequestMapping("/tPermission")
@Api(tags = "权限表相关接口")
public class TPermissionController {
    @Resource
    private TPermissionService permissionService;
    @GetMapping("/list")
    @ApiOperation("查询权限")
//    @RequiredRole(role = {"超级管理员","普通管理员","团队负责人"})
    public Result search() throws Exception {
        List<TPermission> list = permissionService.search();
        return Result.getListResult(TPermission.class).setMsg("查询成功").setData(list);
    }
    //权限分配
    @PostMapping("/insert")
    @ApiOperation("权限分配")
//    @RequiredRole(role = {"超级管理员","普通管理员","团队负责人"})
    public Result insert(Integer roleId,Integer[] resourceId)throws Exception{
        permissionService.insert(roleId,resourceId);
        return Result.getResult(Boolean.class).setMsg("权限分配成功").setData(true);
    }

}

